import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {CreateRepoCompRequestVO, RepoCompPageResult, RepoCompQueryParam,} from './types';

export function listRepoCompEntityPages(queryParams: RepoCompQueryParam): AxiosPromise<RepoCompPageResult> {
    return request({
        url: '/manager/repository/component/model/page',
        method: 'post',
        data: queryParams,
    });
}

export function createRepoCompEntity(data: CreateRepoCompRequestVO) {
    return request({
        url: '/manager/repository/component/model/entity',
        method: 'post',
        data: data,
    });
}

export function updateRepoCompEntity(data: CreateRepoCompRequestVO) {
    return request({
        url: '/manager/repository/component/model/entity',
        method: 'put',
        data: data,
    });
}

export function deleteRepoCompEntity(data: CreateRepoCompRequestVO) {
    return request({
        url: '/manager/repository/component/model/entity',
        method: 'delete',
        params: {
            id: data.id,
        },
    });
}

export function updateRepoCompCommitKey(data: CreateRepoCompRequestVO) {
    return request({
        url: '/manager/repository/component/model/commitKey',
        method: 'put',
        data: {
            id: data.id,
            commitKey: data.commitKey,
        },
    });
}